package cn.stylefeng.guns.modular.menu.controller;


import cn.stylefeng.guns.modular.menu.model.param.CanteenUserParam;
import cn.stylefeng.guns.modular.menu.service.CanteenUserService;
import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * canteen_user 控制器
 *
 * @author:  刘莉
 * @date: 2021/06/16 9:18
 */
@RestController
public class CanteenUserController {

    @Resource
    private CanteenUserService canteenUserService;

    /**
     * 分页查询canteen_user
     *
     * @author  刘莉
     * @date 2021/06/16 9:18
     */
    @GetMapping("/canteenUser/page")
    @BusinessLog(title = "canteen_user_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(CanteenUserParam canteenUserParam) {
        return new SuccessResponseData(canteenUserService.page(canteenUserParam));
    }

    /**
     * 获取全部canteen_user
     *
     * @author  刘莉
     * @date 2021/06/16 9:18
     */
    @GetMapping("/canteenUser/list")
    @BusinessLog(title = "canteen_user_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(CanteenUserParam canteenUserParam) {
        return new SuccessResponseData(canteenUserService.list(canteenUserParam));
    }

    /**
     * 查看详情canteen_user
     *
     * @author  刘莉
     * @date 2021/06/16 9:18
     */
    @GetMapping("/canteenUser/detail")
    @BusinessLog(title = "canteen_user_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(CanteenUserParam.detail.class) CanteenUserParam canteenUserParam) {
        return new SuccessResponseData(canteenUserService.detail(canteenUserParam));
    }

    /**
     * 添加canteen_user
     *
     * @author  刘莉
     * @date 2021/06/16 9:18
     */
    @PostMapping("/canteenUser/add")
    @BusinessLog(title = "canteen_user_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(CanteenUserParam.add.class) CanteenUserParam canteenUserParam) {
        canteenUserService.add(canteenUserParam);
        return new SuccessResponseData();
    }

    /**
     * 删除canteen_user
     *
     * @author  刘莉
     * @date 2021/06/16 9:18
     */
    @PostMapping("/canteenUser/delete")
    @BusinessLog(title = "canteen_user_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(CanteenUserParam.delete.class) CanteenUserParam canteenUserParam) {
        canteenUserService.delete(canteenUserParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑canteen_user
     *
     * @author  刘莉
     * @date 2021/06/16 9:18
     */
    @PostMapping("/canteenUser/edit")
    @BusinessLog(title = "canteen_user_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(CanteenUserParam.edit.class) CanteenUserParam canteenUserParam) {
        canteenUserService.edit(canteenUserParam);
        return new SuccessResponseData();
    }

    /**
     * 修改状态
     *
     * @author  刘莉
     * @date 2021/06/16 9:18
     */
    @PostMapping("/canteenUser/changeStatus")
    @BusinessLog(title = "canteen_user_修改状态", opType = LogAnnotionOpTypeEnum.CHANGE_STATUS)
    public ResponseData changeStatus(@RequestBody @Validated(CanteenUserParam.changeStatus.class) CanteenUserParam canteenUserParam) {
        canteenUserService.changeStatus(canteenUserParam);
        return new SuccessResponseData();
    }

}
